home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows Expert
/
Windows Expert.iso
/
program
/
wintech1.zip
/
PETZOLD.ZIP
/
MENUICON.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-11-05
|
2KB
|
73 lines
/*-----------------------------------------
MENUICON.C -- Adding a Menu and Icon
(c) Charles Petzold, 1991
-----------------------------------------*/
#include <windows.h>
#include "menuicon.h"
BOOL FAR PASCAL DlgProc (HWND, WORD, WORD, LONG) ;
char szAppName [] = "MenuIcon" ;
int PASCAL WinMain (HANDLE hInstance, HANDLE hPrevInstance,
LPSTR lpszCmdLine, int nCmdShow)
{
DialogBox (hInstance, szAppName, NULL,
MakeProcInstance (DlgProc, hInstance)) ;
return 0 ;
}
BOOL FAR PASCAL DlgProc (HWND hwnd, WORD message, WORD wParam, LONG lParam)
{
PAINTSTRUCT ps ;
switch (message)
{
case WM_INITDIALOG:
return TRUE ;
case WM_COMMAND:
switch (wParam)
{
case ID_OPEN:
case ID_SAVE:
MessageBeep (0) ;
return TRUE ;
case ID_EXIT:
SendMessage (hwnd, WM_CLOSE, 0, 0L) ;
return TRUE ;
}
break ;
case WM_ERASEBKGND:
if (IsIconic (hwnd))
return TRUE ;
break ;
case WM_PAINT:
if (IsIconic (hwnd))
{
BeginPaint (hwnd, &ps) ;
DrawIcon (ps.hdc, 0, 0, LoadIcon (NULL, IDI_APPLICATION)) ;
EndPaint (hwnd, &ps) ;
return TRUE ;
}
break ;
case WM_CLOSE:
if (IDOK == MessageBox (hwnd, "Really want to end program?",
szAppName, MB_ICONQUESTION | MB_OKCANCEL))
{
EndDialog (hwnd, 0) ;
return TRUE ;
}
break ;
}
return FALSE ;
}